package com.dyw.springbootpersonal.mapper;

import com.dyw.springbootpersonal.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Devil
 * @create 2022-01-29-19:31
 */
@SuppressWarnings("all")
@Mapper
public interface UserMapper {
    @Select("select * from user order by user_id")
    List<User> getAll();

    @Insert("insert into user values(#{userId},#{userName},#{password},#{gender},#{nickname},#{birthday},#{level},#{isVip},#{registerTime})")
    int insertUser(User user);

    @Delete("delete from user where user_id = #{id}")
    int deleteById(@Param("id") Integer id);

    @Select("select * from user where user_id = #{id} order by user_id")
    User getById(@Param("id") Integer id);

    @Update("update user set user_name = #{userName},password= #{password},gender = #{gender},nickname = #{nickname},birthday = #{birthday},level = #{level},is_vip = #{isVip} where user_id = #{userId}")
    int updateById(User user);
}
